package com.mera.tektronix.csviewer.transformers;

import com.mera.tektronix.csviewer.common.dto.CompanyDto
import com.mera.tektronix.csviewer.domain.Company

public class CompanyTransformer extends AbstractTransformer<CompanyDto, Company> {

	@Override
	protected Company getDomainInstance(CompanyDto dto) {
		if(dto.id != null) {
			return Company.get(dto.id);
		}
		return new Company();
	}

	@Override
	protected CompanyDto getDtoInstance(Company domain) {
		return new CompanyDto();
	}

	@Override
	protected void transformDtoToDomainInternal(CompanyDto dto, Company domain) {		
		domain.name = dto.name;
		domain.email = dto.email;
		domain.address = dto.address;
		domain.phone = dto.phone;
	}

	@Override
	protected void transformDomainToDtoInternal(Company domain, CompanyDto dto) {		
		dto.id = domain.id;
		dto.name = domain.name;
		dto.email = domain.email;
		dto.address = domain.address;
		dto.phone = domain.phone;
	}

}
